let db = require("../db/index");
//水表告警
exports.allWaterMeter = (req, res) => {
    var sql =
        'select * from watermeter';
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send(data);
    });
};
//修改水表数据
exports.updateWaterMeter = (req, res) => {
    const { location, alarmType, valveState, alarmDate, disposeStatus, id } = req.body
    var sql =
        `update watermeter set Location='${location}',AlarmType='${alarmType}',ValveState='${valveState}',AlarmDate='${alarmDate}',DisposeStatus='${disposeStatus}' where ID=${id}`;
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send({
            status: 200
        });
    });
};
//水表充值记录查询
exports.waterRecharge = (req, res) => {
    var sql =
        'select waterrecharge.*,Owner,Phone from waterrecharge,room where room.RoomID=waterrecharge.RoomID';
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send(data);
    });
};